package com.qianfeng.wuyang.himalaya.adapter.recommendfocusadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.qianfeng.wuyang.himalaya.R;
import com.qianfeng.wuyang.himalaya.bean.recommendfocusbean.Associationalbumsinfo;
import com.squareup.picasso.Picasso;
import java.util.List;
/**
 * Created by Administrator on 2016/12/12.
 */
public class RecomendFocusAdaprer extends BaseAdapter {
    private List<Associationalbumsinfo> list;
    private Context context;
    private LayoutInflater inflater;

    public RecomendFocusAdaprer(List<Associationalbumsinfo> list, Context context) {
        this.list = list;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup ){
        VierHolder holder=null;
        if (view == null) {
            view = inflater.inflate(R.layout.recommend_focus_related, viewGroup, false);
            holder = new VierHolder(view);
           view.setTag(holder);
        } else {
            holder = (VierHolder) view.getTag();
        }
        holder.textViewTitle.setText(list.get(i).getTitle());
        holder.textView.setText(list.get(i).getIntro());
        Picasso.with(context)
                .load(list.get(i).getCoverMiddle())
                .into(holder.imageView);


        return view;
    }

    public static class VierHolder {
        TextView textViewTitle;
        ImageView imageView;
        TextView textView;

        public VierHolder(View view) {
            super();
            textViewTitle = (TextView) view.findViewById(R.id.recommendedFocusTextView2);
            textView = (TextView) view.findViewById(R.id.recommendedFocusTextViewBy2);
            imageView = (ImageView) view.findViewById(R.id.recommendedFocusImageview2);
        }
    }
}


